<!DOCTYPE html>
<html lang="en">
<!-- container-fluid -->
<head>
    <title>后台模板</title>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="{{asset(url('css/bootstrap.min.css'))}}" />
    <link rel="stylesheet" href="{{asset(url('css/bootstrap.css'))}}" />
    <link rel="stylesheet" href="{{asset(url('css/bootstrap-responsive.min.css'))}}" />
    <link rel="stylesheet" href="{{asset(url('css/fullcalendar.css'))}}" />
    <link rel="stylesheet" href="{{asset(url('css/unicorn.main.css'))}}" />
    <link rel="stylesheet" href="{{asset(url('css/unicorn.grey.css'))}}" class="skin-color" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="{{asset('js/jquery.js')}}"></script>
    <script type="text/javascript" src="{{asset('layer/layer.js')}}"></script>
</head>
<body>
							<div class="widget-content">
								<table class="table table-bordered table-striped with-check">
									<thead>
										<tr>
											<th>排序</th>
											<th>ID</th>
											<th>用户名</th>
											<th>后台登陆权限</th>
											<th>角色</th>
											<th>操作</th>
										</tr>
									</thead>
									<tbody>
									@foreach($user as $u)
										<tr>
											<td style="line-height:50px"><input type="text" name="ord[]" value="{{$u->order}}" style="width:40px;text-align:center;line-height:50px;margin-bottom:0px" onchange="changeOrder(this,{{$u->id}})"></td>
											<td style="text-align:center;line-height:50px">{{$u->id}}</td>
											<td style="text-align:center;line-height:50px">{{$u->username}}</td>
											<td style="text-align:center;line-height:50px"><button class="btn btn-primary" id="btn{{$u->id}}" onclick="changesta(this,{{$u->id}})">{{$u->status==1?'开启':'关闭'}}</button></td>
											<td style="text-align:center;line-height:50px">{{$u->dname}}</td>
											<td style="text-align:center;line-height:50px"><button type="button" class="btn btn-success"><a href="{{url('Admin/user/'.$u->id. '/edit')}}?page={{$user->currentPage()}}" style="color:white">修改</a></button> | <button type="button" class="btn btn-danger"><a href="javascript:" onclick="delArt({{$u->id}})" style="color:white">删除</a></button> | <button type="button" class="btn btn-danger"><a href="{{url('Admin/role')}}?id={{$u->id}}" style="color:white">添加角色</a></button></td>
										</tr>
										@endforeach

								</table>
								<div class="page">

									{{$user->links()}}

								</div>
								</tbody>
							</div>
	<script type="text/javascript">
                function changeOrder(obj,id){
                    var order = $(obj).val();
                    $.post("{{url('admin/user/changeOrder')}}",{'_token':'{{csrf_token()}}','id':id,'order':order},function(data){
                       console.log(data);
                        if(data.status==0){
                            layer.alert(data.msg, {icon: 6});
                        }else{
                            layer.msg(data.msg, {icon: 5});
                        }
                    });
                }
                function changesta(obj,id){
                    $.post("{{url('admin/user/changeSta')}}",{'_token':'{{csrf_token()}}','id':id},function(data){
                        if(data.status==0){
                            layer.alert(data.msg, {icon: 6});
                             if ($('#btn'+id).html()=='开启') {
                             	$('#btn'+id).html('关闭');
                             }else{
                             	$('#btn'+id).html('开启');
                             }
                        }else{
                            layer.msg(data.msg, {icon: 5});
                        }
                    });
                }
                // 删除友情导航
                function delArt(id){
                    layer.confirm('您确定要删除？', {
                        btn: ['确定','取消'] //按钮
                    }, function(){
                        $.post("{{url('admin/user')}}/"+id,{'_method':'delete','_token':'{{csrf_token()}}'},function(data){
                            if(data.status==0){
                                location.href=location.href;
                                layer.msg(data.msg,{icon:6});
                            }else{
                                layer.msg(data.msg,{icon:5});
                            }
                        });
                    }, function(){
                    });
                }
                $("#chanf").keyup(function () {
                    //数据验证
                    //获取数据
                    var data= $(this).val();
					console.log(data);
                    $.ajax({
                        type:'post',
                        dataType:'json',
                        data:{'data':data,'_token':'{{csrf_token()}}'},
                        url:'{{url('admin/user/chanf')}}',
                        success:function (data) {
                            alert(111);
//                            console.log(data.data.length);
                            {{--var data = data.data[0];--}}
                            {{--$("#sample-table").html("");--}}
                            {{--$(".page").html("");--}}
                            {{--var tr = document.createElement('tr');--}}
                            {{--$(tr).append('<td style="line-height:50px"><input type="text" name="ord[]" value="{{$u->order}}" style="width:40px;text-align:center;line-height:50px;margin-bottom:0px" onchange="changeOrder(this,{{$u->id}})">'+'</td>');--}}
                            {{--$(tr).append('<td style="text-align:center;line-height:50px">'+data['id']+'</td>');--}}
                            {{--$(tr).append('<td style="text-align:center;line-height:50px">'+data['username']+'</td>');--}}
                            {{--$(tr).append('<td style="text-align:center;line-height:50px">'+'<button class="btn btn-primary" id="btn+data[id]" onclick="changesta(this,data['id'])">'+data['status']==1?'开启':'关闭'+'</button>'+'</td>');--}}
                            {{--$(tr).append('<td style="text-align:center;line-height:50px">'+data['name']+'</td>');--}}

                            {{--$("#sample-table").append(tr); --}}


//                            zuijia();


						},
                        error:function (data) {

                            $("#content-header").html(data.responseText);
                        }
                });
                    return false;
                });

			</script>
<script src="{{asset('js/excanvas.min.js')}}"></script>
<script src="{{asset('js/jquery.min.js')}}"></script>
<script src="{{asset('js/jquery.ui.custom.js')}}"></script>
<script src="{{asset('js/bootstrap.min.js')}}"></script>
<script src="{{asset('js/jquery.flot.min.js')}}"></script>
<script src="{{asset('js/jquery.flot.resize.min.js')}}"></script>
<script src="{{asset('js/jquery.peity.min.js')}}"></script>
<script src="{{asset('js/fullcalendar.min.js')}}"></script>
<script src="{{asset('js/unicorn.js')}}"></script>
<script src="{{asset('js/unicorn.dashboard.js')}}"></script>
</body>
</html>
